package org.example.asm;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;

import java.io.File;
import java.io.FileOutputStream;

public class Generator {
    public static void main(String[] args) throws Exception {
        ClassReader classReader = new ClassReader("org/example/asm/ASM");
        ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);

        MyClassVistor myClassVistor = new MyClassVistor(classWriter);
        classReader.accept(myClassVistor,ClassReader.SKIP_DEBUG);

        byte[] bytes = classWriter.toByteArray();
        File file = new File("E:\\gtee\\jvm\\asm\\target\\classes\\org\\example\\asm\\ASM.class");
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        fileOutputStream.write(bytes);
        fileOutputStream.close();

        System.out.println("重新写入成功");
    }
}